// utils/deepseek-sdk.js
class DeepSeekSDK {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://api.deepseek.com/v1';
  }
  
  // 文本生成接口
// 修改 generateText 方法，返回 Promise
async generateText(prompt, options = {}) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: 'https://api.deepseek.com/v1/chat/completions',
      method: 'POST',
      header: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer sk-0d0d3bbdd8c844d68eb2e3e555a35675'
      },
      data: {
        model: 'deepseek-chat',
        messages: [{ role: 'user', content: prompt }]
      },
      success: (res) => {
        // 请求成功时，解析数据并调用 resolve
        if (res.data.choices && res.data.choices.length > 0) {
          resolve(res.data.choices[0].message.content);
        } else {
          reject(new Error('No valid response data'));
        }
      },
      fail: (error) => {
        // 请求失败时，调用 reject
        reject(error);
      }
    });
  });
}
  // 其他API方法...    
}

export default DeepSeekSDK;